<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class ReportAction extends BaseApiAction {

	//举报框
	public function dialog() {
		no_debug();
		$this->auth();
		$this->assign("tweets_id", $_GET["tweets_id"]);
		$this->assign("comment_id", $_GET["comment_id"]);
		$this->display();
	}

	//提交举报
	public function save() {
		$this->auth();
		if ($_POST["tweets_id"]) {
			$data['object_id'] = (int) $_POST["tweets_id"];
			$data['report_type'] = 1;
		} else if ($_POST["comment_id"]) {
			$data['object_id'] = (int) $_POST["comment_id"];
			$data['report_type'] = 2;
		}
		$data['user_id'] = $this->uid;
		$data['content'] = trim($_POST['content']);
		$data['create_time'] = time();
		$data['status'] = 0;
		if ($data['object_id'] == 0)
			$this->ajaxReturn(0, "参数错误", -1);
		if ($data['content'] == "")
			$this->ajaxReturn(0, "必须填写举报原因", -2);
		if (mb_strlen($data['content']) < 20)
			$this->ajaxReturn(0, "原因描述太简单了", -3);
		$result = D("Report")->add($data);
		$this->ajaxReturn($result, "举报成功，请耐心等待管理员处理", 1);
	}
}

?>
